package walls.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import walls.constant.MyConstants;
import walls.entity.R;

@RestControllerAdvice
public class GloableExceptionHandler {

    @ExceptionHandler(AuthException.class)
    public R handleAuthException(AuthException e) {
        e.printStackTrace();
        return R.error(MyConstants.LOGIN_UNAUTHORIZED,e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public R handleAuthException(Exception e) {
        e.printStackTrace();
        return R.error(MyConstants.UNKOWN_ERROR);
    }
}
